package com.publishsystem.filter;

import org.apache.log4j.Logger;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @author fzc
 * @date 2018/8/17 10:52
 */
@WebFilter(filterName = "VerifyLoginFilter")
public class VerifyLoginFilter implements Filter {

    private static Logger logger = Logger.getLogger(VerifyLoginFilter.class);

    @Override
    public void destroy() {
    }

    /**
     * 保证客户管理和app管理模块是登陆状态
     *
     * @param req
     * @param resp
     * @param chain
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        //HttpServletRequest httpServletRequest = (HttpServletRequest) req;
        //String uri = httpServletRequest.getRequestURI();
        //if ((uri.indexOf("/customerAction") >= 0 || uri.indexOf("/customerAction") >= 0) && httpServletRequest.getSession().getAttribute("admin") == null) {//客户管理模块，app管理模块未登录
        //    ((HttpServletResponse) resp).setHeader("content-type", "text/html;charset=UTF-8");
        //    resp.getWriter().print(JsonUtil.toJson(ResultInfo.fail("未登录！")));
        //} else {
            chain.doFilter(req, resp);
        //}
    }

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

}
